package cn.xopencode.userservice.rpc;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.userservice.manager.DeptManager;
import cn.xopencode.userservice.rpc.dept.DeptRpc;
import cn.xopencode.userservice.rpc.dept.dto.*;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @Author xiaodawei
 * @since 2021/9/17
 */
@DubboService(version = "${dubbo.provider.DeptRpc.version}", validation = "false")
public class DeptRpcImpl implements DeptRpc {


    @Autowired
    private DeptManager deptManager;

    @Override
    public CommonResult<String> getDeptIdList(String deptId) {
        return CommonResult.success(deptManager.getDeptIdList(deptId));
    }

    @Override
    public CommonResult<DeptTypeDTO> getDeptTypeName(String userId) {
        return CommonResult.success(deptManager.getDeptTypeDTO(userId));
    }

    @Override
    public CommonResult<String> getDeptNameList(String deptIds) {
        return CommonResult.success(deptManager.getDeptNameList(deptIds));
    }

    @Override
    public CommonResult<DeptDTO> getDept(String deptId) {
        return CommonResult.success(deptManager.getDept(deptId));
    }

    @Override
    public CommonResult<List<DeptDTO>> getDeptList(String parentId) {
        return CommonResult.success(deptManager.getDeptList(parentId));
    }

    @Override
    public CommonResult<String> createDept(CreateDeptDTO createDeptDTO) {
        return CommonResult.success(deptManager.CreateDept(createDeptDTO));
    }

    @Override
    public CommonResult<PageResult<DeptDTO>> findDeptList(DeptPageDTO deptPageDTO) {
        return CommonResult.success(deptManager.findDeptList(deptPageDTO));
    }

    @Override
    public CommonResult<Integer> updateDept(List<UpdateDeptDTO> updateDeptDTOList) {
        return CommonResult.success(deptManager.updateDept(updateDeptDTOList));
    }

    @Override
    public CommonResult<Integer> updateProperty(List<UpdatePropertyDTO> updatePropertyDTOList) {
        return CommonResult.success(deptManager.updateProperty(updatePropertyDTOList));
    }

}
